<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibTools: H:/project/LibTools/src/framework/tcp/framework/Server.cpp 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibTools
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_5752cadd8276ecfd63d9b924f2a4d4b5.html">framework</a></li><li class="navelem"><a class="el" href="dir_c67741c6509c9bd4aec6faa9fd694608.html">tcp</a></li><li class="navelem"><a class="el" href="dir_cf0ab36ee90451b75992f2af7ab5af86.html">framework</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Server.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_server_8cpp.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &quot;../../../socket/internal/IoPortService.h&quot;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &quot;../../../socket/TcpIoServer.h&quot;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &quot;../../../socket/TcpIoSocket.h&quot;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;../../../socket/Timer.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;../../../log/LogFactory.h&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;../ClassFactory.h&quot;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="framework_2tcp_2framework_2_macro_tools_8h.html">MacroTools.h</a>&quot;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_client_8h.html">Client.h</a>&quot;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_server_8h.html">Server.h</a>&quot;</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160; </div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<a class="code" href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160; </div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="class_server.html#a64c508254f64bafca731b8758332bb04">   13</a></span>&#160;<a class="code" href="class_server.html#a64c508254f64bafca731b8758332bb04">Server::Server</a>() :_tcpServer(new <a class="code" href="class_c_tcp_io_server.html">CTcpIoServer</a>()), _svrSock(new <a class="code" href="class_c_tcp_io_socket.html">CTcpIoSocket</a>())</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;{</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    <a class="code" href="class_service.html#a83c9735b06c1d6bd177cb0b8d04ce038">_isServer</a> = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;}</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160; </div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="class_server.html#a4b3aa2579cb1c8cd1d069582c14d0fa6">   18</a></span>&#160;<a class="code" href="class_server.html#a4b3aa2579cb1c8cd1d069582c14d0fa6">Server::~Server</a>()</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;{</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    <a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>.<a class="code" href="class_shared_ptr.html#a0b0a4c8396bf40f91994f729855c0a5a">Reset</a>(<a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>);</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>.<a class="code" href="class_shared_ptr.html#a0b0a4c8396bf40f91994f729855c0a5a">Reset</a>(<a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>);</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;}</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160; </div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="class_server.html#a06de0cc7252d197cbf6f1fdb6887d6c1">   24</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_server.html#a06de0cc7252d197cbf6f1fdb6887d6c1">Server::Init</a>(<span class="keyword">const</span> <a class="code" href="class_tcp_config.html">TcpConfig</a>&amp; c)</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;{</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    *<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a> = c;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <span class="comment">// 套接字初始化</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    <a class="code" href="class_c_sock_error.html">CSockError</a> ec = <a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>-&gt;<a class="code" href="class_c_socket.html#af4c2b2c6e3696ba11c605ee6fead1736">Socket</a>(<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a>-&gt;<a class="code" href="class_tcp_config.html#aeea34692ee7ba49257448a3088d73b61">_family</a>);</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    <a class="code" href="framework_2tcp_2framework_2_macro_tools_8h.html#a353ee81961243d1599c035a0a1b3d9ce">CHECK_SOCKET_ERR_RET</a>(ec, <span class="stringliteral">&quot;socket init failed!&quot;</span>, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    <span class="comment">// 设置地址、端口、端口重用</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>-&gt;<a class="code" href="class_c_socket.html#aafc3fc3ab0c1e3d5ae2cf9dfba46d442">SetDomain</a>(<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a>-&gt;<a class="code" href="class_tcp_config.html#aeea34692ee7ba49257448a3088d73b61">_family</a>);</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    <a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>-&gt;<a class="code" href="class_c_socket.html#afaa6fee02d3a38224445cb42d63d3521">SetAddr</a>(c.<a class="code" href="class_tcp_config.html#a57a14f18ca346a845a54769ab073623c">_addr</a>.c_str());</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>-&gt;<a class="code" href="class_c_socket.html#a112e126a842b4ec30e5d17721ebe73cb">SetPort</a>((<a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a>)c.<a class="code" href="class_tcp_config.html#a96f849454f2f4c873485e15710ea6276">_port</a>);</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <span class="keywordtype">bool</span> ret = this-&gt;<a class="code" href="class_server.html#ac43591a38a0fad67544d6b09d2604f29">SetSocketOpt</a>(<a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>());</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <a class="code" href="framework_2tcp_2framework_2_macro_tools_8h.html#a14116f2c190979f1003fe627c30f104a">CHECK_PARAM_RET</a>(ret, <span class="stringliteral">&quot;set socketopt failed!&quot;</span>, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160; </div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    <span class="comment">// 绑定监听</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    ec = <a class="code" href="_sock_tools_8cpp.html#ac5273d06745110e78bca129577ab2d06">Bind</a>(*<a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>);</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    <a class="code" href="framework_2tcp_2framework_2_macro_tools_8h.html#a353ee81961243d1599c035a0a1b3d9ce">CHECK_SOCKET_ERR_RET</a>(ec, <span class="stringliteral">&quot;Bind server failed!&quot;</span>, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    ec = <a class="code" href="_sock_tools_8cpp.html#abface14c5278330909dd390d3d5a4332">Listen</a>(*<a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>);</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <a class="code" href="framework_2tcp_2framework_2_macro_tools_8h.html#a353ee81961243d1599c035a0a1b3d9ce">CHECK_SOCKET_ERR_RET</a>(ec, <span class="stringliteral">&quot;Listen server failed!&quot;</span>, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160; </div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    ec = <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>-&gt;<a class="code" href="class_c_tcp_io_server.html#aef555ccb9b2f3323c317aea533969442">Init</a>(*<a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>, <span class="keyword">true</span>);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <a class="code" href="framework_2tcp_2framework_2_macro_tools_8h.html#a353ee81961243d1599c035a0a1b3d9ce">CHECK_SOCKET_ERR_RET</a>(ec, <span class="stringliteral">&quot;init server failed!&quot;</span>, <span class="keyword">false</span>);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160; </div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="comment">//PostAccept();</span></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <a class="code" href="_log_factory_8h.html#a3bcb3081cc092adc9e13acb28e70d9e0">LOG_TOOLS</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea">LOG_NORMAL</a>) &lt;&lt; <span class="stringliteral">&quot;bind succ:&quot;</span> &lt;&lt; c.<a class="code" href="class_tcp_config.html#a57a14f18ca346a845a54769ab073623c">_addr</a> &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; c.<a class="code" href="class_tcp_config.html#a96f849454f2f4c873485e15710ea6276">_port</a>;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160; </div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;}</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="class_server.html#ab44f4c14260fc07f2497fa270e7b45f2">   53</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_server.html#ab44f4c14260fc07f2497fa270e7b45f2">Server::Post</a>(<a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a>(*complete)(<span class="keywordtype">void</span>*), <span class="keywordtype">void</span>* invoker)</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;{</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>-&gt;<a class="code" href="class_c_tcp_io_server.html#ae9c8a68befcda8eebb21c5d655eb439f">Post</a>(complete, invoker);</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;}</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="class_server.html#a3513ac8eb75dac27c81720b64aa9b761">   58</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_server.html#a3513ac8eb75dac27c81720b64aa9b761">Server::PostConnect</a>(<span class="keywordtype">void</span>* invoker <span class="comment">/* = NullPtr */</span>, <span class="keyword">const</span> <span class="keywordtype">char</span>* addr <span class="comment">/* = NullPtr */</span>, <a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a> port <span class="comment">/* = 0 */</span>)</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;{</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <a class="code" href="class_server.html#ad78813f16751c1047796440e1c25e455">PostAccept</a>(invoker);</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;}</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="class_server.html#ab42588a62599114c6eee2ca37b4b87d3">   63</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_server.html#ab42588a62599114c6eee2ca37b4b87d3">Server::SetClient</a>(<a class="code" href="class_client.html">Client</a>* c)</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;{</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    c-&gt;<a class="code" href="class_client.html#ab206b489dcd55b5397b6360b62dbb22e">_isClose</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a> = <span class="keyword">this</span>;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    c-&gt;<a class="code" href="class_client.html#aeed5abe9b4741420e5abe29b42c4f621">_timer</a>.<a class="code" href="class_shared_ptr.html#a0b0a4c8396bf40f91994f729855c0a5a">Reset</a>(<span class="keyword">new</span> <a class="code" href="class_c_timer.html">CTimer</a>(<a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>-&gt;<a class="code" href="class_c_tcp_io_server.html#ad0e29bdab15b44c4ea6c9a246424865f">GetTcpServicePtr</a>()));</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    c-&gt;<a class="code" href="class_client.html#ace69bff65ba9f595115c1b80e10f687c">SetSocketOpt</a>(c-&gt;<a class="code" href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">_cliSock</a>.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>());</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;}</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="class_server.html#aab992aaa50dc9378ca89d42d3567ca52">   71</a></span>&#160;<a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a> <a class="code" href="class_server.html#aab992aaa50dc9378ca89d42d3567ca52">Server::AcceptComplete</a>(<a class="code" href="class_c_sock_error.html">CSockError</a> ec, <span class="keywordtype">void</span>* invoker)</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;{</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <a class="code" href="class_client.html">Client</a>* c = (<a class="code" href="class_client.html">Client</a>*)invoker;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a> ret = 0;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <span class="keywordflow">if</span> (ec)</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <a class="code" href="_log_factory_8h.html#a3bcb3081cc092adc9e13acb28e70d9e0">LOG_TOOLS</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9a230506cce5c68c3bac5a821c42ed3473">LOG_ERROR</a>) &lt;&lt; <span class="stringliteral">&quot;accept deal error:&quot;</span> &lt;&lt; ec.GetErrorMsg() &lt;&lt; <span class="stringliteral">&quot;, client id:&quot;</span> &lt;&lt; c-&gt;<a class="code" href="class_client.html#aceeb18e407bb39e5368fa2ab27d66a88">GetClientIden</a>();</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        ret = dynamic_cast&lt;Server*&gt;(c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a>)-&gt;DealConnect(<a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>, ec.GetErrorMsg().c_str(), c-&gt;<a class="code" href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">_invoker</a>);</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    }</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    {</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        ec = dynamic_cast&lt;Server*&gt;(c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a>)-&gt;_tcpServer-&gt;Init(*c-&gt;<a class="code" href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">_cliSock</a>);</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        <span class="keywordflow">if</span> (!ec)</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        {</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;            <a class="code" href="_log_factory_8h.html#a3bcb3081cc092adc9e13acb28e70d9e0">LOG_TOOLS</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea">LOG_NORMAL</a>) &lt;&lt; <span class="stringliteral">&quot;accept succ socket = &quot;</span> &lt;&lt; c-&gt;<a class="code" href="class_client.html#a7eedb09b405e65dfdb88700d35d7b382">GetSocket</a>() &lt;&lt; <span class="stringliteral">&quot;, client id = &quot;</span> &lt;&lt; c-&gt;<a class="code" href="class_client.html#aceeb18e407bb39e5368fa2ab27d66a88">GetClientIden</a>();</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;            dynamic_cast&lt;Server*&gt;(c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a>)-&gt;SetClient(c);</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;            ret = (<a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a>)dynamic_cast&lt;Server*&gt;(c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a>)-&gt;DealConnect(c, <a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>, c-&gt;<a class="code" href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">_invoker</a>);</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        }</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keywordflow">else</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        {</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;            <a class="code" href="_log_factory_8h.html#a3bcb3081cc092adc9e13acb28e70d9e0">LOG_TOOLS</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9a230506cce5c68c3bac5a821c42ed3473">LOG_ERROR</a>) &lt;&lt; <span class="stringliteral">&quot;accept deal error:&quot;</span> &lt;&lt; ec.GetErrorMsg() &lt;&lt; <span class="stringliteral">&quot;, client id:&quot;</span> &lt;&lt; c-&gt;<a class="code" href="class_client.html#aceeb18e407bb39e5368fa2ab27d66a88">GetClientIden</a>();</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;            ret = dynamic_cast&lt;Server*&gt;(c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a>)-&gt;DealConnect(<a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>, ec.GetErrorMsg().c_str(), c-&gt;<a class="code" href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">_invoker</a>);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;            c-&gt;<a class="code" href="class_client.html#aaf6a8239f1f36ef898d289860d7dacb3">Close</a>();</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    }</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <span class="comment">// 根据用户传入的返回值选择是否继续投递接收请求</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <span class="keywordflow">if</span> (ret == 0) {</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        dynamic_cast&lt;Server*&gt;(c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a>)-&gt;PostAccept(c-&gt;<a class="code" href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">_invoker</a>);</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    }</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160; </div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <span class="keywordflow">return</span> ret;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;}</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160; </div>
<div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="class_server.html#af419749ec5a94748acbbaf4f8d9163f1">  106</a></span>&#160;<a class="code" href="class_c_basic_service.html">CBasicService</a>* <a class="code" href="class_server.html#af419749ec5a94748acbbaf4f8d9163f1">Server::GetTcpService</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>-&gt;<a class="code" href="class_c_tcp_io_server.html#ad0e29bdab15b44c4ea6c9a246424865f">GetTcpServicePtr</a>();</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;}</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160; </div>
<div class="line"><a name="l00111"></a><span class="lineno"><a class="line" href="class_server.html#ad78813f16751c1047796440e1c25e455">  111</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_server.html#ad78813f16751c1047796440e1c25e455">Server::PostAccept</a>(<span class="keywordtype">void</span>* invoker)</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;{</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="comment">// 投递第一个请求</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    <a class="code" href="class_shared_ptr.html">SharedPtr&lt;Client&gt;</a> c(this-&gt;<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a>-&gt;<a class="code" href="class_tcp_config.html#a41473b0f5b097059e3e9b38df132928b">_clientFactory</a>-&gt;<a class="code" href="class_client_factory.html#a2c25b038c71194786ee5a1dbd21d5f79">GetClient</a>(), <a class="code" href="struct_release_client.html">ReleaseClient</a>(this-&gt;<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a>-&gt;<a class="code" href="class_tcp_config.html#a41473b0f5b097059e3e9b38df132928b">_clientFactory</a>.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>()));</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    c-&gt;<a class="code" href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">_service</a> = <span class="keyword">this</span>;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    c-&gt;<a class="code" href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">_invoker</a> = invoker;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    c-&gt;<a class="code" href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">_cliSock</a>.<a class="code" href="class_shared_ptr.html#a0b0a4c8396bf40f91994f729855c0a5a">Reset</a>(<span class="keyword">new</span> <a class="code" href="class_c_tcp_io_socket.html">CTcpIoSocket</a>());</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    c-&gt;<a class="code" href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">_cliSock</a>-&gt;<a class="code" href="class_c_tcp_io_socket.html#a6684a9f52783e84a4ff345aa12bc2974">SetAccept</a>(<a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>());</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    this-&gt;<a class="code" href="class_service.html#aceb078ac7bb78b45f21e0a3d2bf79735">AddClient</a>(c);</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160; </div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    c-&gt;<a class="code" href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">_cliSock</a>-&gt;<a class="code" href="class_c_tcp_io_socket.html#aba0dd7f75bd1164192bc354e85361586">AsyncAccept</a>(&amp;<a class="code" href="class_server.html#aab992aaa50dc9378ca89d42d3567ca52">Server::AcceptComplete</a>, c.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>());</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <a class="code" href="_log_factory_8h.html#a3bcb3081cc092adc9e13acb28e70d9e0">LOG_TOOLS</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea">LOG_NORMAL</a>) &lt;&lt; <span class="stringliteral">&quot;PostConnect client_id:&quot;</span> &lt;&lt; c-&gt;<a class="code" href="class_client.html#aceeb18e407bb39e5368fa2ab27d66a88">GetClientIden</a>();</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;}</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160; </div>
<div class="line"><a name="l00125"></a><span class="lineno"><a class="line" href="class_server.html#afec0f8da7ecb6830cb903b87be79c26f">  125</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="class_server.html#afec0f8da7ecb6830cb903b87be79c26f">Server::DealConnect</a>(<a class="code" href="class_client.html">Client</a>* c, <span class="keyword">const</span> <span class="keywordtype">char</span>* msg, <span class="keywordtype">void</span>* invoker)</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;{</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    <span class="keywordflow">if</span> (c)</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    {</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        c-&gt;<a class="code" href="class_client.html#ace69bff65ba9f595115c1b80e10f687c">SetSocketOpt</a>(c-&gt;<a class="code" href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">_cliSock</a>.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>());</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;        c-&gt;<a class="code" href="class_client.html#a95dc32ad76a8bde7a525408d03b842ed">Start</a>(c-&gt;<a class="code" href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">_invoker</a>);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a>-&gt;<a class="code" href="class_tcp_config.html#adc8a522e63eff042bf08252904830918">_timeout</a> != 0) c-&gt;<a class="code" href="class_client.html#adfe1866466f5be9eca92dd6319eb56c1">SetTimeout</a>(<a class="code" href="class_c_unit_time.html">CUnitTime</a>(<a class="code" href="class_service.html#ac215518825547a80c089e9166d4f5e72">_config</a>-&gt;<a class="code" href="class_tcp_config.html#adc8a522e63eff042bf08252904830918">_timeout</a>));</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    }</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160; </div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;}</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160; </div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="line" href="class_server.html#a7c31d308dd9b23132e9912352696ac26">  137</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_server.html#a7c31d308dd9b23132e9912352696ac26">Server::Run</a>()</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;{</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>-&gt;<a class="code" href="class_c_tcp_io_server.html#ad7d8f89bea7573233ee25d4802ae2ab1">Run</a>();</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;}</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160; </div>
<div class="line"><a name="l00142"></a><span class="lineno"><a class="line" href="class_server.html#a2370cd5731a2c120dc705af3acbe46b8">  142</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_server.html#a2370cd5731a2c120dc705af3acbe46b8">Server::NotifyExit</a>()</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;{</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>-&gt;<a class="code" href="class_c_tcp_io_server.html#addea632498b2adb1a24972ffc6c25231">NotifyStop</a>();</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;}</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160; </div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<a class="code" href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_c_socket_html_a112e126a842b4ec30e5d17721ebe73cb"><div class="ttname"><a href="class_c_socket.html#a112e126a842b4ec30e5d17721ebe73cb">CSocket::SetPort</a></div><div class="ttdeci">virtual void SetPort(DWORD port)</div><div class="ttdoc">设置远程或本地端口</div><div class="ttdef"><b>Definition:</b> <a href="_socket_8cpp_source.html#l00166">Socket.cpp:166</a></div></div>
<div class="ttc" id="aclass_tcp_config_html_a41473b0f5b097059e3e9b38df132928b"><div class="ttname"><a href="class_tcp_config.html#a41473b0f5b097059e3e9b38df132928b">TcpConfig::_clientFactory</a></div><div class="ttdeci">SharedPtr&lt; ClientFactory &gt; _clientFactory</div><div class="ttdoc">客户端类工厂</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00044">TcpConf.h:44</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html_aef555ccb9b2f3323c317aea533969442"><div class="ttname"><a href="class_c_tcp_io_server.html#aef555ccb9b2f3323c317aea533969442">CTcpIoServer::Init</a></div><div class="ttdeci">CSockError Init(CTcpIoSocket &amp;sock, bool isServer=false)</div><div class="ttdoc">初始化套接字与服务类设备进行绑定</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00033">TcpIoServer.h:33</a></div></div>
<div class="ttc" id="aclass_c_sock_error_html"><div class="ttname"><a href="class_c_sock_error.html">CSockError</a></div><div class="ttdoc">套接字错误信息类</div><div class="ttdef"><b>Definition:</b> <a href="_sock_error_8h_source.html#l00013">SockError.h:13</a></div></div>
<div class="ttc" id="aclass_c_socket_html_afaa6fee02d3a38224445cb42d63d3521"><div class="ttname"><a href="class_c_socket.html#afaa6fee02d3a38224445cb42d63d3521">CSocket::SetAddr</a></div><div class="ttdeci">virtual void SetAddr(const char *addr)</div><div class="ttdoc">设置远程或本地地址</div><div class="ttdef"><b>Definition:</b> <a href="_socket_8cpp_source.html#l00171">Socket.cpp:171</a></div></div>
<div class="ttc" id="aclass_c_socket_html_aafc3fc3ab0c1e3d5ae2cf9dfba46d442"><div class="ttname"><a href="class_c_socket.html#aafc3fc3ab0c1e3d5ae2cf9dfba46d442">CSocket::SetDomain</a></div><div class="ttdeci">virtual void SetDomain(SOCKFAMILY::SockFamily domain=SOCKFAMILY::IPV4)</div><div class="ttdoc">设置协议族,注意重置该值将会清空地址、端口信息</div><div class="ttdef"><b>Definition:</b> <a href="_socket_8cpp_source.html#l00181">Socket.cpp:181</a></div></div>
<div class="ttc" id="a_server_8h_html"><div class="ttname"><a href="_server_8h.html">Server.h</a></div></div>
<div class="ttc" id="aclass_server_html_ad78813f16751c1047796440e1c25e455"><div class="ttname"><a href="class_server.html#ad78813f16751c1047796440e1c25e455">Server::PostAccept</a></div><div class="ttdeci">void PostAccept(void *invoker)</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00111">Server.cpp:111</a></div></div>
<div class="ttc" id="aclass_shared_ptr_html"><div class="ttname"><a href="class_shared_ptr.html">SharedPtr</a></div><div class="ttdoc">智能指针</div><div class="ttdef"><b>Definition:</b> <a href="_shared_ptr_8h_source.html#l00119">SharedPtr.h:119</a></div></div>
<div class="ttc" id="aclass_client_html_aeed5abe9b4741420e5abe29b42c4f621"><div class="ttname"><a href="class_client.html#aeed5abe9b4741420e5abe29b42c4f621">Client::_timer</a></div><div class="ttdeci">SharedPtr&lt; CTimer &gt; _timer</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00104">Client.h:104</a></div></div>
<div class="ttc" id="aclass_shared_ptr_html_a0f15d2d3d2834b0667791f3abfd9e0d7"><div class="ttname"><a href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">SharedPtr::Get</a></div><div class="ttdeci">Ty * Get()</div><div class="ttdef"><b>Definition:</b> <a href="_shared_ptr_8h_source.html#l00202">SharedPtr.h:202</a></div></div>
<div class="ttc" id="aclass_client_html_a4889e8635ac9c85685cca164608dc4f8"><div class="ttname"><a href="class_client.html#a4889e8635ac9c85685cca164608dc4f8">Client::_invoker</a></div><div class="ttdeci">void * _invoker</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00105">Client.h:105</a></div></div>
<div class="ttc" id="aclass_server_html_a3513ac8eb75dac27c81720b64aa9b761"><div class="ttname"><a href="class_server.html#a3513ac8eb75dac27c81720b64aa9b761">Server::PostConnect</a></div><div class="ttdeci">virtual void PostConnect(void *invoker=NullPtr, const char *addr=NullPtr, DWORD port=0)</div><div class="ttdoc">投递一个接收请求，参数将会被忽略</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00058">Server.cpp:58</a></div></div>
<div class="ttc" id="aclass_client_html_ab206b489dcd55b5397b6360b62dbb22e"><div class="ttname"><a href="class_client.html#ab206b489dcd55b5397b6360b62dbb22e">Client::_isClose</a></div><div class="ttdeci">bool _isClose</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00106">Client.h:106</a></div></div>
<div class="ttc" id="aclass_server_html_af419749ec5a94748acbbaf4f8d9163f1"><div class="ttname"><a href="class_server.html#af419749ec5a94748acbbaf4f8d9163f1">Server::GetTcpService</a></div><div class="ttdeci">virtual CBasicService * GetTcpService() const</div><div class="ttdoc">获取tcp底层类指针</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00106">Server.cpp:106</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html"><div class="ttname"><a href="class_c_tcp_io_server.html">CTcpIoServer</a></div><div class="ttdoc">tcp io服务端服务类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00011">TcpIoServer.h:11</a></div></div>
<div class="ttc" id="atools_8h_html_a201ce692c9dca6599e5c12d00167419b"><div class="ttname"><a href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div><div class="ttdeci">#define DEF_BEG_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00036">tools.h:36</a></div></div>
<div class="ttc" id="aframework_2tcp_2framework_2_macro_tools_8h_html_a14116f2c190979f1003fe627c30f104a"><div class="ttname"><a href="framework_2tcp_2framework_2_macro_tools_8h.html#a14116f2c190979f1003fe627c30f104a">CHECK_PARAM_RET</a></div><div class="ttdeci">#define CHECK_PARAM_RET(param, logmsg, ret)</div><div class="ttdef"><b>Definition:</b> <a href="framework_2tcp_2framework_2_macro_tools_8h_source.html#l00005">MacroTools.h:5</a></div></div>
<div class="ttc" id="aclass_tcp_config_html"><div class="ttname"><a href="class_tcp_config.html">TcpConfig</a></div><div class="ttdoc">客户端配置类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00018">TcpConf.h:18</a></div></div>
<div class="ttc" id="aclass_server_html_a4b3aa2579cb1c8cd1d069582c14d0fa6"><div class="ttname"><a href="class_server.html#a4b3aa2579cb1c8cd1d069582c14d0fa6">Server::~Server</a></div><div class="ttdeci">virtual ~Server()</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00018">Server.cpp:18</a></div></div>
<div class="ttc" id="aclass_tcp_config_html_a96f849454f2f4c873485e15710ea6276"><div class="ttname"><a href="class_tcp_config.html#a96f849454f2f4c873485e15710ea6276">TcpConfig::_port</a></div><div class="ttdeci">int _port</div><div class="ttdoc">监听端口</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00039">TcpConf.h:39</a></div></div>
<div class="ttc" id="aclass_client_html_adfe1866466f5be9eca92dd6319eb56c1"><div class="ttname"><a href="class_client.html#adfe1866466f5be9eca92dd6319eb56c1">Client::SetTimeout</a></div><div class="ttdeci">virtual void SetTimeout(const CTimeBase &amp;t)</div><div class="ttdoc">设置超时,派生类可以重写此功能以便重设</div><div class="ttdef"><b>Definition:</b> <a href="_client_8cpp_source.html#l00116">Client.cpp:116</a></div></div>
<div class="ttc" id="aclass_server_html_ac27a342724c595745fea924a5ec116c6"><div class="ttname"><a href="class_server.html#ac27a342724c595745fea924a5ec116c6">Server::_tcpServer</a></div><div class="ttdeci">SharedPtr&lt; CTcpIoServer &gt; _tcpServer</div><div class="ttdoc">tcp服务类</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00071">Server.h:71</a></div></div>
<div class="ttc" id="aclass_service_html_ac215518825547a80c089e9166d4f5e72"><div class="ttname"><a href="class_service.html#ac215518825547a80c089e9166d4f5e72">Service::_config</a></div><div class="ttdeci">SharedPtr&lt; TcpConfig &gt; _config</div><div class="ttdoc">配置文件</div><div class="ttdef"><b>Definition:</b> <a href="_service_8h_source.html#l00114">Service.h:114</a></div></div>
<div class="ttc" id="aclass_client_html_a95dc32ad76a8bde7a525408d03b842ed"><div class="ttname"><a href="class_client.html#a95dc32ad76a8bde7a525408d03b842ed">Client::Start</a></div><div class="ttdeci">virtual bool Start(void *invoker)</div><div class="ttdoc">开始任务，继承者可实现此函数进行处理</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00026">Client.h:26</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html_ad7d8f89bea7573233ee25d4802ae2ab1"><div class="ttname"><a href="class_c_tcp_io_server.html#ad7d8f89bea7573233ee25d4802ae2ab1">CTcpIoServer::Run</a></div><div class="ttdeci">bool Run()</div><div class="ttdoc">运行服务</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00111">TcpIoServer.h:111</a></div></div>
<div class="ttc" id="aclass_server_html_ab44f4c14260fc07f2497fa270e7b45f2"><div class="ttname"><a href="class_server.html#ab44f4c14260fc07f2497fa270e7b45f2">Server::Post</a></div><div class="ttdeci">virtual void Post(DWORD(*complete)(void *), void *invoker)</div><div class="ttdoc">投递一个用户操作</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00053">Server.cpp:53</a></div></div>
<div class="ttc" id="alogdef_8h_html_aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea"><div class="ttname"><a href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea">LOG_NORMAL</a></div><div class="ttdef"><b>Definition:</b> <a href="logdef_8h_source.html#l00013">logdef.h:13</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html_ae9c8a68befcda8eebb21c5d655eb439f"><div class="ttname"><a href="class_c_tcp_io_server.html#ae9c8a68befcda8eebb21c5d655eb439f">CTcpIoServer::Post</a></div><div class="ttdeci">void Post(const Func &amp;func)</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00098">TcpIoServer.h:98</a></div></div>
<div class="ttc" id="aclass_c_unit_time_html"><div class="ttname"><a href="class_c_unit_time.html">CUnitTime</a></div><div class="ttdoc">时间单位类 以毫秒为单位的一个时间度量</div><div class="ttdef"><b>Definition:</b> <a href="_time_8h_source.html#l00170">Time.h:170</a></div></div>
<div class="ttc" id="aframework_2tcp_2framework_2_macro_tools_8h_html"><div class="ttname"><a href="framework_2tcp_2framework_2_macro_tools_8h.html">MacroTools.h</a></div></div>
<div class="ttc" id="aclass_server_html_ab42588a62599114c6eee2ca37b4b87d3"><div class="ttname"><a href="class_server.html#ab42588a62599114c6eee2ca37b4b87d3">Server::SetClient</a></div><div class="ttdeci">void SetClient(Client *c)</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00063">Server.cpp:63</a></div></div>
<div class="ttc" id="atools_8h_html_ac909db71799bb22cb7d636a34cd785e4"><div class="ttname"><a href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div><div class="ttdeci">#define DEF_END_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00038">tools.h:38</a></div></div>
<div class="ttc" id="aclass_server_html_a06de0cc7252d197cbf6f1fdb6887d6c1"><div class="ttname"><a href="class_server.html#a06de0cc7252d197cbf6f1fdb6887d6c1">Server::Init</a></div><div class="ttdeci">virtual bool Init(const TcpConfig &amp;c)</div><div class="ttdoc">初始化服务,主要用于绑定监听一个地址端口</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00024">Server.cpp:24</a></div></div>
<div class="ttc" id="a_client_8h_html"><div class="ttname"><a href="_client_8h.html">Client.h</a></div></div>
<div class="ttc" id="aclass_client_factory_html_a2c25b038c71194786ee5a1dbd21d5f79"><div class="ttname"><a href="class_client_factory.html#a2c25b038c71194786ee5a1dbd21d5f79">ClientFactory::GetClient</a></div><div class="ttdeci">virtual Client * GetClient()=0</div><div class="ttdoc">生产一个client</div></div>
<div class="ttc" id="aclass_server_html_a7c31d308dd9b23132e9912352696ac26"><div class="ttname"><a href="class_server.html#a7c31d308dd9b23132e9912352696ac26">Server::Run</a></div><div class="ttdeci">virtual bool Run()</div><div class="ttdoc">运行服务</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00137">Server.cpp:137</a></div></div>
<div class="ttc" id="aclass_server_html_a64c508254f64bafca731b8758332bb04"><div class="ttname"><a href="class_server.html#a64c508254f64bafca731b8758332bb04">Server::Server</a></div><div class="ttdeci">Server()</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00013">Server.cpp:13</a></div></div>
<div class="ttc" id="aclass_client_html_a5922d4b508779e8788fdbd3a6d137b01"><div class="ttname"><a href="class_client.html#a5922d4b508779e8788fdbd3a6d137b01">Client::_service</a></div><div class="ttdeci">Service * _service</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00107">Client.h:107</a></div></div>
<div class="ttc" id="aclass_shared_ptr_html_a0b0a4c8396bf40f91994f729855c0a5a"><div class="ttname"><a href="class_shared_ptr.html#a0b0a4c8396bf40f91994f729855c0a5a">SharedPtr::Reset</a></div><div class="ttdeci">void Reset(Ty *p)</div><div class="ttdef"><b>Definition:</b> <a href="_shared_ptr_8h_source.html#l00175">SharedPtr.h:175</a></div></div>
<div class="ttc" id="aclass_server_html_ac43591a38a0fad67544d6b09d2604f29"><div class="ttname"><a href="class_server.html#ac43591a38a0fad67544d6b09d2604f29">Server::SetSocketOpt</a></div><div class="ttdeci">virtual bool SetSocketOpt(CTcpIoSocket *s)</div><div class="ttdoc">设置套接字额外选项</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00063">Server.h:63</a></div></div>
<div class="ttc" id="a_sock_tools_8cpp_html_ac5273d06745110e78bca129577ab2d06"><div class="ttname"><a href="_sock_tools_8cpp.html#ac5273d06745110e78bca129577ab2d06">Bind</a></div><div class="ttdeci">CSockError Bind(CSocket &amp;sock, const char *szAddr, DWORD port)</div><div class="ttdoc">绑定套接字端口</div><div class="ttdef"><b>Definition:</b> <a href="_sock_tools_8cpp_source.html#l00033">SockTools.cpp:33</a></div></div>
<div class="ttc" id="alogdef_8h_html_aca1fd1d8935433e6ba2e3918214e07f9a230506cce5c68c3bac5a821c42ed3473"><div class="ttname"><a href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9a230506cce5c68c3bac5a821c42ed3473">LOG_ERROR</a></div><div class="ttdef"><b>Definition:</b> <a href="logdef_8h_source.html#l00015">logdef.h:15</a></div></div>
<div class="ttc" id="astruct_release_client_html"><div class="ttname"><a href="struct_release_client.html">ReleaseClient</a></div><div class="ttdef"><b>Definition:</b> <a href="_class_factory_8h_source.html#l00058">ClassFactory.h:58</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_socket_html_a6684a9f52783e84a4ff345aa12bc2974"><div class="ttname"><a href="class_c_tcp_io_socket.html#a6684a9f52783e84a4ff345aa12bc2974">CTcpIoSocket::SetAccept</a></div><div class="ttdeci">virtual void SetAccept(CTcpIoSocket *acceptSock)</div><div class="ttdoc">设置服务类的监听套接字</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_socket_8h_source.html#l00071">TcpIoSocket.h:71</a></div></div>
<div class="ttc" id="aclass_server_html_afec0f8da7ecb6830cb903b87be79c26f"><div class="ttname"><a href="class_server.html#afec0f8da7ecb6830cb903b87be79c26f">Server::DealConnect</a></div><div class="ttdeci">virtual int DealConnect(Client *c, const char *msg, void *invoker)</div><div class="ttdoc">处理接收函数，子类可重写此处理</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00125">Server.cpp:125</a></div></div>
<div class="ttc" id="atools_8h_html_a798af1e30bc65f319c1a246cecf59e39"><div class="ttname"><a href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a></div><div class="ttdeci">unsigned int DWORD</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00134">tools.h:134</a></div></div>
<div class="ttc" id="aclass_client_html_aaf6a8239f1f36ef898d289860d7dacb3"><div class="ttname"><a href="class_client.html#aaf6a8239f1f36ef898d289860d7dacb3">Client::Close</a></div><div class="ttdeci">virtual void Close()</div><div class="ttdoc">关闭客户端</div><div class="ttdef"><b>Definition:</b> <a href="_client_8cpp_source.html#l00104">Client.cpp:104</a></div></div>
<div class="ttc" id="aclass_client_html_ace69bff65ba9f595115c1b80e10f687c"><div class="ttname"><a href="class_client.html#ace69bff65ba9f595115c1b80e10f687c">Client::SetSocketOpt</a></div><div class="ttdeci">virtual void SetSocketOpt(CTcpIoSocket *s)</div><div class="ttdoc">设置套接字选项, 派生类可重写此函数以设置更多的套接字选项</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00061">Client.h:61</a></div></div>
<div class="ttc" id="aframework_2tcp_2framework_2_macro_tools_8h_html_a353ee81961243d1599c035a0a1b3d9ce"><div class="ttname"><a href="framework_2tcp_2framework_2_macro_tools_8h.html#a353ee81961243d1599c035a0a1b3d9ce">CHECK_SOCKET_ERR_RET</a></div><div class="ttdeci">#define CHECK_SOCKET_ERR_RET(ec, logmsg, ret)</div><div class="ttdef"><b>Definition:</b> <a href="framework_2tcp_2framework_2_macro_tools_8h_source.html#l00004">MacroTools.h:4</a></div></div>
<div class="ttc" id="atools_8h_html_ab689500aaec0db066e3ac9483d3fe425"><div class="ttname"><a href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a></div><div class="ttdeci">#define NullPtr</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00119">tools.h:119</a></div></div>
<div class="ttc" id="aclass_c_timer_html"><div class="ttname"><a href="class_c_timer.html">CTimer</a></div><div class="ttdoc">定时器</div><div class="ttdef"><b>Definition:</b> <a href="_timer_8h_source.html#l00069">Timer.h:69</a></div></div>
<div class="ttc" id="aclass_c_socket_html_af4c2b2c6e3696ba11c605ee6fead1736"><div class="ttname"><a href="class_c_socket.html#af4c2b2c6e3696ba11c605ee6fead1736">CSocket::Socket</a></div><div class="ttdeci">virtual CSockError Socket(SOCKFAMILY::SockFamily domain=SOCKFAMILY::IPV4, SOCKTYPE::SockType type=SOCKTYPE::STREAM, SOCKPROTOCOL::SockProtocol protocol=SOCKPROTOCOL::TCP)</div><div class="ttdoc">初始化套接字</div><div class="ttdef"><b>Definition:</b> <a href="_socket_8cpp_source.html#l00068">Socket.cpp:68</a></div></div>
<div class="ttc" id="a_sock_tools_8cpp_html_abface14c5278330909dd390d3d5a4332"><div class="ttname"><a href="_sock_tools_8cpp.html#abface14c5278330909dd390d3d5a4332">Listen</a></div><div class="ttdeci">CSockError Listen(CSocket &amp;sock, int backlog)</div><div class="ttdoc">监听套接字</div><div class="ttdef"><b>Definition:</b> <a href="_sock_tools_8cpp_source.html#l00067">SockTools.cpp:67</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html_ad0e29bdab15b44c4ea6c9a246424865f"><div class="ttname"><a href="class_c_tcp_io_server.html#ad0e29bdab15b44c4ea6c9a246424865f">CTcpIoServer::GetTcpServicePtr</a></div><div class="ttdeci">CBasicService * GetTcpServicePtr()</div><div class="ttdoc">获取底层服务类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00142">TcpIoServer.h:142</a></div></div>
<div class="ttc" id="aclass_c_basic_service_html"><div class="ttname"><a href="class_c_basic_service.html">CBasicService</a></div><div class="ttdoc">服务类 基类</div><div class="ttdef"><b>Definition:</b> <a href="_service_base_8h_source.html#l00015">ServiceBase.h:15</a></div></div>
<div class="ttc" id="aclass_tcp_config_html_a57a14f18ca346a845a54769ab073623c"><div class="ttname"><a href="class_tcp_config.html#a57a14f18ca346a845a54769ab073623c">TcpConfig::_addr</a></div><div class="ttdeci">std::string _addr</div><div class="ttdoc">监听地址</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00040">TcpConf.h:40</a></div></div>
<div class="ttc" id="aclass_server_html_aab992aaa50dc9378ca89d42d3567ca52"><div class="ttname"><a href="class_server.html#aab992aaa50dc9378ca89d42d3567ca52">Server::AcceptComplete</a></div><div class="ttdeci">static DWORD AcceptComplete(CSockError ec, void *invoker)</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00071">Server.cpp:71</a></div></div>
<div class="ttc" id="a_log_factory_8h_html_a3bcb3081cc092adc9e13acb28e70d9e0"><div class="ttname"><a href="_log_factory_8h.html#a3bcb3081cc092adc9e13acb28e70d9e0">LOG_TOOLS</a></div><div class="ttdeci">#define LOG_TOOLS(LEVEL)</div><div class="ttdoc">日志流操作宏工具</div><div class="ttdef"><b>Definition:</b> <a href="_log_factory_8h_source.html#l00013">LogFactory.h:13</a></div></div>
<div class="ttc" id="aclass_client_html_aceeb18e407bb39e5368fa2ab27d66a88"><div class="ttname"><a href="class_client.html#aceeb18e407bb39e5368fa2ab27d66a88">Client::GetClientIden</a></div><div class="ttdeci">virtual std::string GetClientIden() const</div><div class="ttdoc">获取客户端唯一标识</div><div class="ttdef"><b>Definition:</b> <a href="_client_8cpp_source.html#l00046">Client.cpp:46</a></div></div>
<div class="ttc" id="aclass_tcp_config_html_adc8a522e63eff042bf08252904830918"><div class="ttname"><a href="class_tcp_config.html#adc8a522e63eff042bf08252904830918">TcpConfig::_timeout</a></div><div class="ttdeci">int _timeout</div><div class="ttdoc">超时时间,单位毫秒，为0则不设置超时值</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00038">TcpConf.h:38</a></div></div>
<div class="ttc" id="aclass_client_html_a7eedb09b405e65dfdb88700d35d7b382"><div class="ttname"><a href="class_client.html#a7eedb09b405e65dfdb88700d35d7b382">Client::GetSocket</a></div><div class="ttdeci">virtual int GetSocket() const</div><div class="ttdoc">获取socket描述符</div><div class="ttdef"><b>Definition:</b> <a href="_client_8cpp_source.html#l00036">Client.cpp:36</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_socket_html"><div class="ttname"><a href="class_c_tcp_io_socket.html">CTcpIoSocket</a></div><div class="ttdoc">用于tcp进行io投递的套接字类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_socket_8h_source.html#l00017">TcpIoSocket.h:17</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_socket_html_aba0dd7f75bd1164192bc354e85361586"><div class="ttname"><a href="class_c_tcp_io_socket.html#aba0dd7f75bd1164192bc354e85361586">CTcpIoSocket::AsyncAccept</a></div><div class="ttdeci">void AsyncAccept(const Func &amp;func)</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_socket_8h_source.html#l00104">TcpIoSocket.h:104</a></div></div>
<div class="ttc" id="aclass_client_html"><div class="ttname"><a href="class_client.html">Client</a></div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00012">Client.h:12</a></div></div>
<div class="ttc" id="aclass_client_html_ac9ef3d3342a564f93d6d94ee795a28c0"><div class="ttname"><a href="class_client.html#ac9ef3d3342a564f93d6d94ee795a28c0">Client::_cliSock</a></div><div class="ttdeci">SharedPtr&lt; CTcpIoSocket &gt; _cliSock</div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00103">Client.h:103</a></div></div>
<div class="ttc" id="aclass_service_html_a83c9735b06c1d6bd177cb0b8d04ce038"><div class="ttname"><a href="class_service.html#a83c9735b06c1d6bd177cb0b8d04ce038">Service::_isServer</a></div><div class="ttdeci">bool _isServer</div><div class="ttdoc">服务端标志</div><div class="ttdef"><b>Definition:</b> <a href="_service_8h_source.html#l00116">Service.h:116</a></div></div>
<div class="ttc" id="aclass_server_html_ae87994e288d29da1f351d80ed04f387b"><div class="ttname"><a href="class_server.html#ae87994e288d29da1f351d80ed04f387b">Server::_svrSock</a></div><div class="ttdeci">SharedPtr&lt; CTcpIoSocket &gt; _svrSock</div><div class="ttdoc">服务套接字</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00072">Server.h:72</a></div></div>
<div class="ttc" id="aclass_server_html_a2370cd5731a2c120dc705af3acbe46b8"><div class="ttname"><a href="class_server.html#a2370cd5731a2c120dc705af3acbe46b8">Server::NotifyExit</a></div><div class="ttdeci">virtual void NotifyExit()</div><div class="ttdoc">通知Run函数退出</div><div class="ttdef"><b>Definition:</b> <a href="_server_8cpp_source.html#l00142">Server.cpp:142</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html_addea632498b2adb1a24972ffc6c25231"><div class="ttname"><a href="class_c_tcp_io_server.html#addea632498b2adb1a24972ffc6c25231">CTcpIoServer::NotifyStop</a></div><div class="ttdeci">void NotifyStop()</div><div class="ttdoc">通知服务停止</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00124">TcpIoServer.h:124</a></div></div>
<div class="ttc" id="aclass_tcp_config_html_aeea34692ee7ba49257448a3088d73b61"><div class="ttname"><a href="class_tcp_config.html#aeea34692ee7ba49257448a3088d73b61">TcpConfig::_family</a></div><div class="ttdeci">SOCKFAMILY::SockFamily _family</div><div class="ttdoc">ip协议 默认IPV4</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00036">TcpConf.h:36</a></div></div>
<div class="ttc" id="aclass_service_html_aceb078ac7bb78b45f21e0a3d2bf79735"><div class="ttname"><a href="class_service.html#aceb078ac7bb78b45f21e0a3d2bf79735">Service::AddClient</a></div><div class="ttdeci">void AddClient(const SharedPtr&lt; Client &gt; &amp;c)</div><div class="ttdoc">增加客户端</div><div class="ttdef"><b>Definition:</b> <a href="_service_8cpp_source.html#l00049">Service.cpp:49</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
